package org.df.ulab.bot.api.communication;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

import org.df.ulab.bot.api.message.Message;

/**
 * @author Daniel Filgueiras
 * @since 19/06/2011
 */
public interface CommunicationService extends Runnable {

	static final AtomicInteger TOKEN = new AtomicInteger();
	
	int getUniqueId();
	
	boolean stopService();
	
	BlockingQueue<Message> getIncome();
	
	boolean post(Message mesage);
	boolean subscribe(String remoteId);
	boolean unsubscribe(String remoteId);
	
	void reply(Message message, CharSequence alert);
	void reply(Message message, DefaultMsgs msg);
	
	
	public enum DefaultMsgs {
		Accepted,
		Unknown_Command,
		Command_Execution_Failed,
		Initialization_Error,
		Database_connection_is_not_estabilished, 
		Unable_to_connect_to_web_server,
		Unauthorize_User,
		;
		public String toString() {
			return "_" + this.name().replace('_', ' ') + "_";	//Italic: _text_
		};
	}
}
